<template>
  <div class="">用户资料

    <div style="margin-top: 20px;"></div>
    <el-form
    :label-position="labelPosition"
    label-width="100px"
    :model="formLabelAlign"
    style="max-width: 460px"
  >
    <el-form-item label="用户名">
      <el-input v-model="formLabelAlign.username" disabled="disabled:" />
    </el-form-item>
    <el-form-item label="昵称">
      <el-input v-model="formLabelAlign.name"/>
    </el-form-item>
  </el-form>
  <el-button type="primary" @click="onSubmit" style="margin-left: 120px;">保存</el-button>

  <div style=" margin-top: 30px; text-align: center; color: blue; font-size: 50px;">文章统计图</div>
  <div>
    <echarts />
  </div>
  </div>
</template>

<script setup lang = "ts">
import {ref } from 'vue';

import { type FormProps,ElMessage } from 'element-plus'
import {instance} from '@/utils/MyRequeest'
import echarts from '@/components/uplode/Echarts/ZhiLiaoEcharts.vue'
const labelPosition = ref<FormProps['labelPosition']>('right')

const formLabelAlign = ref({
  name: '',
  username: '',
})
function onSubmit() {
  instance({
    method:'put',
    url:'/user/update',
    data:{
      name:formLabelAlign.value.name
    }
  }).then(()=>{
    ElMessage.success("保存成功")
location.reload()    
  })
}
instance({
  method:'get',
  url:'user/getuser'
}).
then((res)=>{
  formLabelAlign.value.name = res.data.data.name
  formLabelAlign.value.username = res.data.data.username
})
</script>

<style lang="css" scoped></style>